{% extends 'TopxiaWebBundle::bootstrap-modal-layout.html.twig' %}

{% set modal_class = 'modal-lg' %}

{% set replaceFor= replaceFor|default(null) %}

{% block title %}试卷{% if replaceFor %}替换{% else %}添加{% endif %}题目{% endblock %}

{% block body %}

  <form id="testpaper-item-picker-form" class="form-inline well well-sm" action="{{ path('course_manage_testpaper_item_picker', {courseId:course.id, testpaperId:testpaper.id}) }}" novalidate>
    <div class="form-group">
      <select class="form-control" name="target" style="width:200px;height:32px;">
        {{ select_options(targetChoices, app.request.query.get('target'), '--按从属--') }}
      </select>
    </div>

    <div class="form-group">
      <input type="text" id="keyword" name="keyword" class="form-control" value="{{ app.request.query.get('keyword') }}" placeholder="关键词">
    </div>

    <input type="hidden" name="excludeIds" value="{{ conditions.excludeIds|join(',') }}">
    <input type="hidden" name="type" value="{{ conditions.type }}">
    <input type="hidden" name="replace" value="{{ replace }}">

    <button class="btn btn-primary btn-sm">搜索</button>

  </form>

	
  <table class="table table-condensed" id="testpaper-item-picker-table">
    <thead>
    <tr>
	  <th><input type="checkbox" data-role="question-add-select" /></th>
      <th width="45%">题干</th>
      <th>类型</th>
      <th>分值</th>
      <th>操作</th>
    </tr>
    </thead>
    <tbody>
      {% for question in questions %}
        {% include 'TopxiaWebBundle:CourseTestpaperManage:item-pick-tr.html.twig' %}
      {% else %}
        <tr><td colspan="20"><div class="empty">无题目记录</div></td></tr>
      {% endfor %}
	  <tr>
	  <td  colspan="20" id = "queding"></td>  <!-- wuliang zujuan 组卷 -->
	</tr>
    </tbody>
  </table>
<!-- wuliang zujuan 组卷 -->
	  <script>
		var path = "{{ path('course_manage_testpaper_item_picked', {courseId:course.id, testpaperId:testpaper.id }) }}";
		var queding = document.getElementById("queding");
		{% if not replace %}
		queding.innerHTML = '<button type="button" id="btn" class="btn btn-primary btn-sm" data-role="picked-item" data-replace="{{ replace|default('') }}" data-url="'+path+'">选择</button>';
		{% endif %}
	</script>
<!-- wuliang zujuan 组卷 -->
	
  {{ web_macro.paginator(paginator) }}

  <script>app.load('testpaper/item-picker')</script>

{% endblock %}

{% block footer %}
    <button type="button" class="btn btn-default pull-right" data-dismiss="modal" data-toggle="form-submit" data-target="#block-form">关闭</button>
{% endblock %}